//
// Decompiled by Jadx - 460ms
//
package fg;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.constraintlayout.widget.i;
import cc.u;
import cf.f;
import com.bumptech.glide.b;
import com.bumptech.glide.m;
import com.bumptech.glide.n;
import da.a;
import da.d;
import fn.y;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import me.plusne.common.Json.JsonWxMessage;
import r.g;

public final class x extends BaseAdapter {
    public static final int a = 0;
    public List<JsonWxMessage> b = new ArrayList();
    public final LayoutInflater c = LayoutInflater.from(y.by.getActivity());

    @Override
    public final int getCount() {
        List<JsonWxMessage> list = this.b;
        if (list == null) {
            return 0;
        }
        return list.size();
    }

    @Override
    public final Object getItem(int i) {
        List<JsonWxMessage> list = this.b;
        if (list == null) {
            return null;
        }
        return list.get(i);
    }

    @Override
    public final long getItemId(int i) {
        return 0L;
    }

    /* JADX WARN: Removed duplicated region for block: B:39:0x0182  */
    /* JADX WARN: Removed duplicated region for block: B:42:0x01ad  */
    /* JADX WARN: Removed duplicated region for block: B:45:0x01e7  */
    /* JADX WARN: Removed duplicated region for block: B:51:0x01f8  */
    /* JADX WARN: Removed duplicated region for block: B:52:0x0185  */
    @Override
    @SuppressLint({"SetTextI18n"})
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final View getView(int i, View view, ViewGroup viewGroup) {
        u uVar;
        m u;
        String str;
        int type;
        CharSequence charSequence;
        String str2;
        String uuid;
        PackageInfo packageInfo = null;
        if (view == null) {
            View inflate = this.c.inflate(-2113142699, (ViewGroup) null, false);
            int i2 = 0x7f820055;
            ImageView imageView = (ImageView) i.cg(0x7f820055, inflate);
            if (imageView != null) {
                i2 = 0x7f820084;
                TextView textView = (TextView) i.cg(0x7f820084, inflate);
                if (textView != null) {
                    i2 = 0x7f820113;
                    LinearLayout linearLayout = (LinearLayout) i.cg(0x7f820113, inflate);
                    if (linearLayout != null) {
                        i2 = 0x7f820162;
                        ImageView imageView2 = (ImageView) i.cg(0x7f820162, inflate);
                        if (imageView2 != null) {
                            i2 = 0x7f8201b2;
                            TextView textView2 = (TextView) i.cg(0x7f8201b2, inflate);
                            if (textView2 != null) {
                                i2 = 0x7f82021c;
                                TextView textView3 = (TextView) i.cg(0x7f82021c, inflate);
                                if (textView3 != null) {
                                    LinearLayout linearLayout2 = (LinearLayout) inflate;
                                    uVar = new u(linearLayout2, imageView, textView, linearLayout, imageView2, textView2, textView3);
                                    linearLayout2.setTag(uVar);
                                }
                            }
                        }
                    }
                }
            }
            throw new NullPointerException("Missing required view with ID: ".concat(inflate.getResources().getResourceName(i2)));
        }
        uVar = (u) view.getTag();
        JsonWxMessage jsonWxMessage = this.b.get(i);
        if (jsonWxMessage != null) {
            g.v(uVar.e, -2113535894);
            boolean isEmpty = TextUtils.isEmpty(jsonWxMessage.getUserName_img_url());
            ImageView imageView3 = uVar.b;
            if (isEmpty) {
                if (jsonWxMessage.getDrawableId() != 0) {
                    Activity activity = y.by.getActivity();
                    n o = b.m(activity).o(activity);
                    Integer valueOf = Integer.valueOf(jsonWxMessage.getDrawableId());
                    o.getClass();
                    m mVar = new m(o.b, o, Drawable.class, o.c);
                    m u2 = mVar.u(valueOf);
                    ConcurrentHashMap concurrentHashMap = da.b.a;
                    Context context = mVar.a;
                    String packageName = context.getPackageName();
                    ConcurrentHashMap concurrentHashMap2 = da.b.a;
                    f fVar = (f) concurrentHashMap2.get(packageName);
                    if (fVar == null) {
                        try {
                            packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
                        } catch (PackageManager.NameNotFoundException e) {
                            Log.e("AppVersionSignature", "Cannot resolve info for" + context.getPackageName(), e);
                        }
                        if (packageInfo != null) {
                            uuid = String.valueOf(packageInfo.versionCode);
                        } else {
                            uuid = UUID.randomUUID().toString();
                        }
                        fVar = new d(uuid);
                        f fVar2 = (f) concurrentHashMap2.putIfAbsent(packageName, fVar);
                        if (fVar2 != null) {
                            fVar = fVar2;
                        }
                    }
                    u = u2.p(new cx.g().bg(new a(context.getResources().getConfiguration().uiMode & 48, fVar)));
                }
                StringBuilder sb = new StringBuilder();
                sb.append(jsonWxMessage.getNickname());
                if (!TextUtils.isEmpty(jsonWxMessage.getAlias())) {
                    str = "";
                } else {
                    str = "(" + jsonWxMessage.getAlias() + ")";
                }
                sb.append(str);
                String sb2 = sb.toString();
                if (!TextUtils.isEmpty(jsonWxMessage.getKey())) {
                    sb2 = sb2.replaceAll(jsonWxMessage.getKey(), "<font color='#CC33FF'>" + jsonWxMessage.getKey() + "</font>");
                }
                TextView textView4 = uVar.f;
                textView4.setText(g.w(textView4, sb2));
                uVar.g.setText(jsonWxMessage.getUserName());
                type = jsonWxMessage.getType();
                TextView textView5 = uVar.c;
                if (type == -1) {
                    if (jsonWxMessage.getType() == 1) {
                        str2 = "<font color='#0088FF'>密友已隐藏</font>";
                    } else {
                        str2 = "<font color='#00E080'>密友未隐藏</font>";
                    }
                    charSequence = g.w(textView5, str2);
                } else {
                    charSequence = "非密友";
                }
                textView5.setText(charSequence);
                imageView3.setOnClickListener(new fh.a(2, jsonWxMessage));
                View.OnClickListener tVar = new t(5, uVar, jsonWxMessage);
                uVar.e.setOnClickListener(tVar);
                textView4.setOnClickListener(tVar);
                textView5.setOnClickListener(tVar);
                uVar.d.setOnClickListener(tVar);
            } else {
                Activity activity2 = y.by.getActivity();
                n o2 = b.m(activity2).o(activity2);
                String userName_img_url = jsonWxMessage.getUserName_img_url();
                o2.getClass();
                u = new m(o2.b, o2, Drawable.class, o2.c).u(userName_img_url);
            }
            u.ax().s(imageView3);
            StringBuilder sb3 = new StringBuilder();
            sb3.append(jsonWxMessage.getNickname());
            if (!TextUtils.isEmpty(jsonWxMessage.getAlias())) {
            }
            sb3.append(str);
            String sb22 = sb3.toString();
            if (!TextUtils.isEmpty(jsonWxMessage.getKey())) {
            }
            TextView textView42 = uVar.f;
            textView42.setText(g.w(textView42, sb22));
            uVar.g.setText(jsonWxMessage.getUserName());
            type = jsonWxMessage.getType();
            TextView textView52 = uVar.c;
            if (type == -1) {
            }
            textView52.setText(charSequence);
            imageView3.setOnClickListener(new fh.a(2, jsonWxMessage));
            View.OnClickListener tVar2 = new t(5, uVar, jsonWxMessage);
            uVar.e.setOnClickListener(tVar2);
            textView42.setOnClickListener(tVar2);
            textView52.setOnClickListener(tVar2);
            uVar.d.setOnClickListener(tVar2);
        }
        return uVar.a;
    }
}
